//
//  UPOrderCategoryCell.m
//  LoveFreshBee
//
//  Created by 王现涛 on 16/6/12.
//  Copyright © 2016年 王现涛. All rights reserved.
//

#import "UPOrderCategoryCell.h"
#import "UPOrderCategoryModel.h"
@interface UPOrderCategoryCell()
@property (weak, nonatomic) IBOutlet UIView *leftLine;
@property (weak, nonatomic) IBOutlet UILabel *categoryNameLabel;
@property (weak, nonatomic) IBOutlet UIImageView *rightImageView;

@end
@implementation UPOrderCategoryCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.categoryNameLabel.textColor=UPColor(169, 169, 169);
    }
/**
 *  设置cell的selected为none
 *  设置线为hidden
 *  选中哪个cell就让哪个cell左边的线显示出来
 */
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    self.leftLine.hidden=!selected;//选中哪个cell就让哪个cell左边的线显示出来
//    self.backgroundColor=(selected)?[UIColor whiteColor]:[UIColor clearColor];//选中"某个"cell变成白色 点击其它 "某个"cell变回原来颜色
    if (selected) {
        self.backgroundColor=[UIColor whiteColor];
        self.categoryNameLabel.textColor=[UIColor blackColor];
        //选中"某个"cell变成白色 点击其它 "某个"cell变回原来颜色
    }else{
        self.backgroundColor=[UIColor clearColor];
        self.categoryNameLabel.textColor=UPColor(169, 169, 169);
    }
    
    
    
}
-(void)setModel:(UPOrderCategoryModel *)model{
    _model=model;
    self.categoryNameLabel.text=model.name;
    if (model.flag.length) {
         //下载图片
        dispatch_queue_t
        queue=dispatch_queue_create("abc",NULL);
        dispatch_async(queue, ^{
             NSURL *url=[NSURL URLWithString:model.flag];
            NSData *data=[NSData dataWithContentsOfURL:url];
            dispatch_async(dispatch_get_main_queue(), ^{
                UIImage *img=[UIImage imageWithData:data];
                self.rightImageView.image=img;
            });
        });
    }
}








@end
